/**
 * Created by Administrator on 2017/5/3 0003.
 */
//创建XMLHttpRequest
function createXHR(){
    if(window.XMLHttpRequest){
        return new XMLHttpRequest();
    }
    return new ActiveXObject("Microsoft.XMLHTTP");
}

//创建ajax
function ajax(url,fn){
    var xhr=new createXHR();

    xhr.open("get",url,true);
    xhr.send(null);

    xhr.onreadystatechange=function(){
        if(xhr.readyState==4){
            if(xhr.status==200){
                fn(xhr.responseText);
            }
        }
    }
}